import request from '@/utils/request.js'
// import store from '@/store'
/**
 * 发送验证码
 * @param {*} mobile  手机号
 * @returns promise
 *  return 作用：因为request为promise  await修饰的promise 不 return的话，
 * 返回的是undefined,只有return 返回的才是promise
 */
export const sendCode = (mobile) => {
  return request({
    url: '/v1_0/sms/codes/' + mobile
  })
}
/**
 *
 * @param {*} data { mobile,code}
 * @returns promise 返回值
 */
export const login = (data) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data
  })
}
/**
 * 获取用户自己的信息
 * @returns promise
 */
export const getUserInfo = () => {
  return request({
    url: '/v1_0/user',
    method: 'GET'
    // headers: {
    //   Authorization: 'Bearer ' + store.state.user.token
    // }
  })
}
export const getUserChannels = () => {
  return request({
    url: '/v1_0/user/channels',
    method: 'GET'
  })
}
/**
 *添加用户关注
 * @param {*} target 关注的用户id
 * @returns promise
 */

export const addFollowUser = target => {
  return request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: {
      target
    }
  })
}
/**
 *删除用户关注
 * @param {*} target 关注的用户id
 * @returns promise
 */
export const removeFollowUser = target => {
  return request({
    url: '/v1_0/user/followings/' + target,
    method: 'DELETE'
  })
}
